"""
主页
"""
from selenium.webdriver.common.by import By
from page.base_page import BasePage

class IndexPage(BasePage):
    url="/crm/index.php?m=dynamic&a=index"
    #个人资料定位器
    touxiang_locator = (By.XPATH, "/html/body/div[1]/div/div/div[2]/ul[2]/li[6]/a/img")
    personal_data_btn_locator = (By.LINK_TEXT, "个人资料")
    client_locator = (By.XPATH, "/html/body/div[1]/div/div/div[2]/ul[1]/li[2]/a")
    user_name_locator=(By.XPATH,"/html/body/div[1]/div/div/div[2]/ul[2]/li[6]/a")
    # 商机页定位器
    btn_sj_locator = (By.LINK_TEXT, "商机")
    # 产品页定位器
    btn_cp_locator = (By.LINK_TEXT, "产品")
    # 合同页定位器
    btn_ht_locator = (By.LINK_TEXT, "合同")
    # 线索定位器
    clue_locator = (By.LINK_TEXT, '线索')
    # 更多按钮定位器
    more_locator = (By.LINK_TEXT, '更多')
    # 站内信定位器
    mail_locator = (By.LINK_TEXT, '站内信')
    # 主页中任务模块
    task_locator = (By.LINK_TEXT, '任务')
    # 页面日程
    schedule_locator = (By.LINK_TEXT, '日程')







    #点击主页头像
    def click_touxiang(self):
        self.driver.find_element(*self.touxiang_locator).click()
    #点击个人资料
    def click_person_data_btn(self):
        self.driver.find_element(*self.personal_data_btn_locator).click()
    # 点击客户
    def click_client(self):
        self.driver.find_element(*self.client_locator).click()
    def check_username(self):
        username=self.driver.find_element(*self.user_name_locator).text
        return username.strip()
    def click_cp(self):
        '''点击主页产品按钮'''
        self.driver.find_element(*self.btn_cp_locator).click()
    def click_sj(self):
        '''点击主页商机按钮'''
        self.driver.find_element(*self.btn_sj_locator).click()
    def click_ht(self):
        '''点击主页合同按钮'''
        self.driver.find_element(*self.btn_ht_locator).click()
    # 点击线索
    def click_clue(self):
        self.driver.find_element(*self.clue_locator).click()
    # 点击更多
    def click_more(self):
        self.driver.find_element(*self.more_locator).click()
    # 点击站内信
    def click_mail(self):
        self.driver.find_element(*self.mail_locator).click()
    # 点击任务
    def click_task(self):
        self.driver.find_element(*self.task_locator).click()
     # 点击日程
    def click_schedule(self):
        self.driver.find_element(*self.schedule_locator).click()

    #获取当前页面地址
    def get_current_url(self):
        return self.driver.current_url

